﻿<Window
  x:Class='Shazzam.MainWindow'
  xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
  xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
  xmlns:converters='clr-namespace:Shazzam.Converters'
  xmlns:commands='clr-namespace:Shazzam.Commands'
  xmlns:view='clr-namespace:Shazzam.Views'
  Title='Shazzam Shader Editor = V1.2'
  WindowState='Maximized'
  Background='Black'
  xmlns:d='http://schemas.microsoft.com/expression/blend/2008'
  xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006'
  mc:Ignorable='d'
  Icon='Images/star.png'
  xmlns:vms='clr-namespace:Shazzam.ViewModels'>
  <Window.Resources>

    <converters:StringToVisibilityConverter
      x:Key='visConverter' />
    <converters:StretchToIsCheckedConverter
      x:Key='checkedConverter' />
    <vms:MainWindowViewModel
      x:Key='mainVM' />
    <SolidColorBrush
      x:Key='ImageBorderBrush'
      Color='#FF16404C' />
    <DrawingBrush
      x:Key="AlphaGrid"
      TileMode="Tile"
      Viewport="0 0 8 8"
      ViewportUnits="Absolute"
      Stretch="UniformToFill">
      <DrawingBrush.Drawing>
        <DrawingGroup>
          <GeometryDrawing
            Brush="Gray">
            <GeometryDrawing.Geometry>
              <GeometryGroup>
                <RectangleGeometry
                  Rect="0 0 10 10" />
                <RectangleGeometry
                  Rect="10 10 10 10" />
              </GeometryGroup>
            </GeometryDrawing.Geometry>
          </GeometryDrawing>
        </DrawingGroup>
      </DrawingBrush.Drawing>
    </DrawingBrush>

  </Window.Resources>
  <Window.CommandBindings>
    <CommandBinding
      Command='ApplicationCommands.New'
      Executed='New_Executed' />
    <CommandBinding
      Command='ApplicationCommands.Open'
      Executed='Open_Executed' />
    <CommandBinding
      Command='commands:AppCommands.OpenImage'
      Executed='OpenImage_Executed' />
    <CommandBinding
      Command='commands:AppCommands.OpenMedia'
      Executed='OpenMedia_Executed' />
    <CommandBinding
      Command='ApplicationCommands.Save'
      Executed='Save_Executed' />
    <CommandBinding
      Command='ApplicationCommands.SaveAs'
      Executed='SaveAs_Executed' />
    <CommandBinding
      Command='commands:AppCommands.Exit'
      Executed='Exit_Executed' />

    <CommandBinding
      Command='commands:AppCommands.ApplyShader'
      Executed='ApplyShader_Executed'
      CanExecute='ShaderCommand_CanExecute' />
    <CommandBinding
      Command='commands:AppCommands.RemoveShader'
      Executed='RemoveShader_Executed' />
    <CommandBinding
      Command='commands:AppCommands.CompileShader'
      Executed='CompileShader_Executed'
      CanExecute='ShaderCommand_CanExecute' />
    <!--<CommandBinding Command='commands:AppCommands.ExploreCompiledShaders'
                    Executed='ExploreCompiledShaders_Executed' />-->
    <!--<CommandBinding Command='commands:AppCommands.ExploreTextureMaps'
                    Executed='ExploreTextureMaps_Executed' />-->

    <!--<CommandBinding Command='commands:AppCommands.FullScreenImage'
                    Executed='FullScreenImage_Executed' />-->
    <!--<CommandBinding Command='commands:AppCommands.FullScreenCode'
                    Executed='FullScreenCode_Executed' />-->
    <!--<CommandBinding Command='commands:AppCommands.ImageStretch'
                    Executed='ImageStretch_Executed' />-->

  </Window.CommandBindings>

  <Grid
    Background="#101010"
    x:Name='mainGrid'
    DataContext='{StaticResource mainVM}'>
    <Grid.Resources>

    </Grid.Resources>
    <Grid.ColumnDefinitions>
      <ColumnDefinition
        x:Name="PluginsColumn"
        Width="Auto" />
      <ColumnDefinition
        Width="*" />
    </Grid.ColumnDefinitions>
    <StackPanel
      Grid.Column='0'>
      <Grid
        x:Name='menuContainer'>

        <Grid
          Margin="0,5,0,5">
          <Border
            BorderBrush="#484848"
            BorderThickness="0,0,1,0"
            CornerRadius="0,4,4,0">
            <Border.Background>
              <LinearGradientBrush
                StartPoint="0,0"
                EndPoint="0,1">
                <GradientStop
                  Offset="0.0"
                  Color="#484848" />
                <GradientStop
                  Offset="1.0"
                  Color="#282828" />
              </LinearGradientBrush>
            </Border.Background>
          </Border>

          <Border
            BorderBrush="{StaticResource HighlightBrush}"
            BorderThickness="0,1,0,0"
            CornerRadius="0,4,0,0"
            VerticalAlignment="Top"
            Height="25">
            <Border.Background>
              <LinearGradientBrush
                StartPoint="0,0"
                EndPoint="0,1">
                <GradientStop
                  Offset="0.0"
                  Color="#505050" />
                <GradientStop
                  Offset="1.0"
                  Color="#282828" />
              </LinearGradientBrush>
            </Border.Background>
          </Border>

          <Border
            BorderBrush="#777"
            BorderThickness="0,1,0,0"
            CornerRadius="0,4,4,0" />
          <Border
            BorderBrush="#404040"
            BorderThickness="0,0,0,1"
            CornerRadius="0,4,4,0" />
          <Border
            CornerRadius="0,0,4,0"
            VerticalAlignment="Bottom"
            Height="33"
            BorderBrush="{StaticResource HighlightBrush}"
            Opacity='.4'
            BorderThickness="0,1,0,0">
            <Border.Background>
              <LinearGradientBrush
                StartPoint="0,0"
                EndPoint="0,1">
                <GradientStop
                  Color="#10FFFFFF"
                  Offset="0" />
                <GradientStop
                  Color="#00FFFFFF"
                  Offset="1" />
              </LinearGradientBrush>
            </Border.Background>
          </Border>
        </Grid>

        <Menu
          Background='Black'
          Grid.Column='0'
          VerticalAlignment="Top"
          Height="24"
          Margin="0,6,1,0">
          <MenuItem
            Header='_File'>
            <MenuItem
              Header='_New_Shader File...'
              Command='ApplicationCommands.New' />
            <MenuItem
              Header='Open _Shader File...'
              Command='ApplicationCommands.Open' />
            <MenuItem
              Header='Open _Image File...'
              Command='commands:AppCommands.OpenImage' />
            <MenuItem
              Header='Open _Media File...'
              Command='commands:AppCommands.OpenMedia' />
            <Separator />
            <MenuItem
              Header='_Save'
              Command='ApplicationCommands.Save' />
            <MenuItem
              Header='Save _As...'
              Command='ApplicationCommands.SaveAs' />
            <Separator />
            <MenuItem
              Header='E_xit'
              Command='commands:AppCommands.Exit' />
          </MenuItem>

          <MenuItem
            Header='_Edit'
            Visibility='Collapsed'>
            <MenuItem
              Header='_Undo'
              Command='ApplicationCommands.Undo' />
            <MenuItem
              Header='_Redo'
              Command='ApplicationCommands.Redo' />
            <Separator />
            <MenuItem
              Header='_Cut'
              Command='ApplicationCommands.Cut' />
            <MenuItem
              Header='C_opy'
              Command='ApplicationCommands.Copy' />
            <MenuItem
              Header='_Paste'
              Command='ApplicationCommands.Paste' />
            <Separator />
            <MenuItem
              Header='Find'
              Command='ApplicationCommands.Find' />
          </MenuItem>

          <MenuItem
            Header='_Tools'>
            <MenuItem
              Header='_Apply Shader'
              Command='commands:AppCommands.ApplyShader' />
            <MenuItem
              Header='_Remove Shader'
              Command='commands:AppCommands.RemoveShader' />
            <MenuItem
              Header='_Compile Shader'
              Command='commands:AppCommands.CompileShader' />
            <Separator />
            <MenuItem
              Header='_Explore Compiled Shaders (*.ps)'
              Command='{Binding ExploreCompiledShadersCommand}' />
            <MenuItem
              Header='_Explore Texture Maps'
              Command='{Binding ExploreTextureMapsCommand}' />
          </MenuItem>

          <MenuItem
            Header='_View'>
            <MenuItem
              Header='Full Screen _Image'
              InputGestureText="F9"
              Command='{Binding FullScreenImageCommand}' />
            <MenuItem
              Header='Full Screen _Code'
              InputGestureText="F11"
              Command='{Binding FullScreenCodeCommand}' />
            <Separator />
            <MenuItem
              Header="Image _Stretch">
              <MenuItem
                Header="_None"
                IsCheckable='True'
                Command="{Binding ImageStretchCommand}"
                CommandParameter='none'
                InputGestureText="Ctrl+F5"
                IsChecked='{Binding ImageStretch,
                        ConverterParameter=none,
                        Converter={StaticResource checkedConverter}}'>

              </MenuItem>
              <MenuItem
                Header="_Fill"
                IsCheckable='True'
                InputGestureText="Ctrl+F6"
                Command="{Binding ImageStretchCommand}"
                CommandParameter='fill'
                IsChecked='{Binding ImageStretch,
                        ConverterParameter=fill,
                        Converter={StaticResource checkedConverter}}'>
              </MenuItem>
              <MenuItem
                Header="_Uniform"
                IsCheckable='True'
                Command="{Binding ImageStretchCommand}"
                CommandParameter='uniform'
                InputGestureText="Ctrl+F7"
                IsChecked='{Binding ImageStretch,
                        ConverterParameter=uniform,
                        Converter={StaticResource checkedConverter}}' />
              <MenuItem
                Header="Uniform_ToFill"
                IsCheckable='True'
                Command="{Binding ImageStretchCommand}"
                CommandParameter='uniformtofill'
                InputGestureText="Ctrl+F8"
                IsChecked='{Binding ImageStretch,
                        ConverterParameter=uniformtofill,
                        Converter={StaticResource checkedConverter}}' />

            </MenuItem>
          </MenuItem>
          <MenuItem
            Header='_Help'>

            <MenuItem
              Header="What's New"
              Command='{Binding Path=BrowseToSiteCommand}'
              CommandParameter='http://blog.shazzam-tool.com/' />
            <Separator />
          
            <MenuItem
              Header="Report a bug"
              Command='{Binding Path=BrowseToSiteCommand}'
              CommandParameter='http://shazzam.codeplex.com/WorkItem/List.aspx'  />
            <MenuItem
              Header="Forums"
              Command='{Binding Path=BrowseToSiteCommand}'
              CommandParameter='http://shazzam.codeplex.com/Thread/List.aspx' />
            <Separator />
            <MenuItem
              Header="Twitter"
              Command='{Binding Path=BrowseToSiteCommand}'
              CommandParameter='http://twitter.com/shazzamtool' />
            <MenuItem
              Header="Blog"
              Command='{Binding Path=BrowseToSiteCommand}'
              CommandParameter='http://blog.shazzam-tool.com/'/>
            <Separator />
            <MenuItem
              Header="XAML Wonderland"
              Command='{Binding Path=BrowseToSiteCommand}'
              CommandParameter='http://blog.xamlwonderland.com/' />
            <MenuItem
              Header="Contribute"
              Command='{Binding BrowseToSiteCommand}'
              CommandParameter='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=UMKJV7XEKWPV8' />
            <!--<MenuItem Header="Check for Update" />-->
            <Separator />
            <MenuItem
              Header="HLSL and Pixel Shader for .NET Developers Book"
              Command='{Binding Path=BrowseToSiteCommand}'
              CommandParameter='http://amazon.com/' />
            <MenuItem
              Header="Video Training"
              Command='{Binding Path=BrowseToSiteCommand}'
              CommandParameter='http://lynda.com/waltritscher' />
          </MenuItem>

        </Menu>
      </Grid>
      <!--<view:MenuView x:Name='menuView'></view:MenuView>-->
      <view:PluginView
        Margin='10'
        x:Name='plugin1'></view:PluginView>

      <!-- <view:DynamicInputView Margin='10' x:Name='dynamicView' />-->
      <StackPanel
        x:Name='testStack' />
    </StackPanel>
    <Grid
      Grid.Column='1'
      Margin='3,6,0,0'>
      <Grid.RowDefinitions>
        <RowDefinition
          Height='{Binding ImageRowHeight}'
          x:Name='imageRow' />
        <RowDefinition
          Height='4'
          x:Name='splitterRow' />
        <RowDefinition
          Height='{Binding CodeRowHeight}'
          x:Name='codeRow' />
      </Grid.RowDefinitions>

      <GridSplitter
        Grid.Row='1'
        ResizeDirection="Rows"
        HorizontalAlignment="Stretch"
        Width="Auto"
        Grid.ColumnSpan='1' />

      <view:CodeTabView
        x:Name='codeTabView'
        DockPanel.Dock='Bottom'
        Grid.Row='2' />
      <TabControl
        Background='{DynamicResource NeutralDarkBrush}'
        x:Name='imageTabControl'
        SelectionChanged='imageTabControl_SelectionChanged'
        Grid.Row='0'>

        <TabItem
          Header='Custom Image'>
          <Border
            Style='{DynamicResource ImageOutsideBorder}'>
            <Border
              Style='{DynamicResource ImageInsideBorder}'>
              <!-- checkered background-->
              <Border
                Background='{StaticResource AlphaGrid}'>

                <Image
                  x:Name='userImage'
                  Source='Images/ColorRange.png'
                  Stretch='{Binding ImageStretch}'
                  HorizontalAlignment='Center'
                  VerticalAlignment='Center' />
              </Border>
            </Border>
          </Border>
        </TabItem>
        <TabItem
          Header='Sample1'>

          <Border
            Style='{DynamicResource ImageOutsideBorder}'>
            <Border
              Style='{DynamicResource ImageInsideBorder}'>
              <Border
                Background='{StaticResource AlphaGrid}'>
                <Image
                  x:Name='sampleImage1'
                  Source='Images/Fire1.jpg'
                  Stretch='{Binding ImageStretch}'
                  HorizontalAlignment='Center'
                  VerticalAlignment='Center'>

                </Image>
              </Border>
            </Border>
          </Border>
        </TabItem>
        <TabItem
          Header='Sample2'>

          <Border
            Style='{DynamicResource ImageOutsideBorder}'>
            <Border
              Style='{DynamicResource ImageInsideBorder}'>
              <Border
                Background='{StaticResource AlphaGrid}'>
                <Image
                  x:Name='sampleImage2'
                  Source='Images/Light1.jpg'
                  Stretch='{Binding ImageStretch}'
                  HorizontalAlignment='Center'
                  VerticalAlignment='Center' />
              </Border>

            </Border>
          </Border>
        </TabItem>
        <TabItem
          Header='Sample3'>

          <Border
            Style='{DynamicResource ImageOutsideBorder}'>
            <Border
              Style='{DynamicResource ImageInsideBorder}'>
              <Border
                Background='{StaticResource AlphaGrid}'>
                <Image
                  x:Name='sampleImage3'
                  Source='Images/SpikeBalls.jpg'
                  Stretch='{Binding ImageStretch}'
                  HorizontalAlignment='Center'
                  VerticalAlignment='Center' />
              </Border>
            </Border>
          </Border>
        </TabItem>
        <TabItem
          Header='Sample4'>

          <Border
            Style='{DynamicResource ImageOutsideBorder}'>
            <Border
              Style='{DynamicResource ImageInsideBorder}'>
              <Border
                Background='{StaticResource AlphaGrid}'>
                <Image
                  x:Name='sampleImage4'
                  Source='Images/lines.jpg'
                  Stretch='{Binding ImageStretch}'
                  HorizontalAlignment='Center'
                  VerticalAlignment='Center' />
              </Border>
            </Border>
          </Border>
        </TabItem>
        <TabItem
          Header='Sample5'>

          <Border
            Style='{DynamicResource ImageOutsideBorder}'>
            <Border
              Style='{DynamicResource ImageInsideBorder}'>
              <Border
                Background='{StaticResource AlphaGrid}'>
                <Image
                  x:Name='sampleImage5'
                  Source='Images/gears.jpg'
                  Stretch='{Binding ImageStretch}'
                  HorizontalAlignment='Center'
                  VerticalAlignment='Center' />
              </Border>

            </Border>
          </Border>
        </TabItem>
        <TabItem
          Header='Sample UI'>

          <Border
            Background='{StaticResource AlphaGrid}'>
            <DockPanel
              TextElement.FontSize='14'
              x:Name='sampleUI'
              VerticalAlignment='Stretch'
              HorizontalAlignment='Stretch'
              MinHeight='200'
              MinWidth='200'
              LastChildFill="False">
              <DockPanel.Background>
                <LinearGradientBrush
                  EndPoint="0.5,1"
                  StartPoint="0.5,0">
                  <GradientStop
                    Color="#FFBCF3F1"
                    Offset="0" />
                  <GradientStop
                    Color="#FF6558E0"
                    Offset="1" />
                </LinearGradientBrush>
              </DockPanel.Background>
              <TextBlock
                Text='Sample UI'
                FontSize='18'
                DockPanel.Dock='Top'
                Margin='8'
                HorizontalAlignment="Center" />
              <ListBox
                DockPanel.Dock='Top'
                Width='140'
                x:Name='fruitListBox'
                Margin='8'
                HorizontalAlignment='Center'>
                <TextBlock
                  Text='Apple' />
                <TextBlock
                  Text='Banana' />
                <TextBlock
                  Text='Grapes' />
                <TextBlock
                  Text='Peach' />
                <TextBlock
                  Text='Strawberry' />
              </ListBox>
              <StackPanel
                Orientation='Horizontal'
                Margin='8'
                DockPanel.Dock='Top'
                HorizontalAlignment="Center"
                Height="42.5">
                <Button
                  Content='Sample 1'
                  Margin='4'
                  HorizontalAlignment='Left'
                  Click='Button1_Click' />
                <Button
                  Content='Sample 2'
                  Margin='4'
                  HorizontalAlignment='Left'
                  Click='Button2_Click' />
              </StackPanel>
            </DockPanel>
          </Border>

        </TabItem>
        <TabItem
          Header='Media'
          x:Name='mediaTab'>

          <Border
            Style='{DynamicResource ImageOutsideBorder}'>
            <Border
              Style='{DynamicResource ImageInsideBorder}'>
              <Border
                Background='{StaticResource AlphaGrid}'>
                <DockPanel
                  TextElement.FontSize='16'
                  VerticalAlignment='Stretch'
                  HorizontalAlignment='Stretch'
                  MinHeight='200'
                  MinWidth='200'
                  Background='White'>
                  <StackPanel
                    Orientation='Horizontal'
                    DockPanel.Dock='Top'
                    Margin='10'>
                    <!--<TextBlock Text='Click the video to replay.'
                               Margin='5,0' />-->
                    <CheckBox
                      IsChecked='True'
                      Margin='5,0'
                      x:Name='autoPlayCheckBox'
                      Content='Auto replay the video.'
                      Checked='autoPlayCheckBox_Checked'></CheckBox>
                  </StackPanel>
                  <TextBlock
                    Margin='10'
                    DockPanel.Dock='Top'
                    x:Name='videoMessage' />
                  <Border
                    Style='{DynamicResource ImageOutsideBorder}'>
                    <Border
                      Style='{DynamicResource ImageInsideBorder}'>
                      <MediaElement
                        Source='Images/plasma.wmv'
                        DockPanel.Dock='Top'
                        Stretch='{Binding ImageStretch}'
                        x:Name='mediaUI'
                        LoadedBehavior='Manual'
                        ToolTip='Click video to replay.'
                        MouseLeftButtonUp='mediaUI_MouseLeftButtonUp'
                        MediaEnded='mediaUI_MediaEnded'
                        MediaFailed='mediaUI_MediaFailed'>

                      </MediaElement>
                    </Border>
                  </Border>
                </DockPanel>
              </Border>

            </Border>
          </Border>
        </TabItem>
      </TabControl>

      <!--</Grid>-->

    </Grid>
  </Grid>
</Window>